package com.archive.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.archive.common.annotation.Log;
import com.archive.common.core.controller.BaseController;
import com.archive.common.core.domain.AjaxResult;
import com.archive.common.enums.BusinessType;
import com.archive.manage.domain.StuClassInfo;
import com.archive.manage.service.IStuClassInfoService;
import com.archive.common.utils.poi.ExcelUtil;
import com.archive.common.core.page.TableDataInfo;

/**
 * 学生班级信息Controller
 * 
 * @author marioduan
 * @date 2025-04-17
 */
@RestController
@RequestMapping("/manage/classInfo")
public class StuClassInfoController extends BaseController
{
    @Autowired
    private IStuClassInfoService stuClassInfoService;

    /**
     * 查询学生班级信息列表
     */
    @PreAuthorize("@ss.hasPermi('manage:classInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(StuClassInfo stuClassInfo)
    {
        startPage();
        List<StuClassInfo> list = stuClassInfoService.selectStuClassInfoList(stuClassInfo);
        return getDataTable(list);
    }

    /**
     * 导出学生班级信息列表
     */
    @PreAuthorize("@ss.hasPermi('manage:classInfo:export')")
    @Log(title = "学生班级信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StuClassInfo stuClassInfo)
    {
        List<StuClassInfo> list = stuClassInfoService.selectStuClassInfoList(stuClassInfo);
        ExcelUtil<StuClassInfo> util = new ExcelUtil<StuClassInfo>(StuClassInfo.class);
        util.exportExcel(response, list, "学生班级信息数据");
    }

    /**
     * 获取学生班级信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:classInfo:query')")
    @GetMapping(value = "/{studentId}")
    public AjaxResult getInfo(@PathVariable("studentId") String studentId)
    {
        return success(stuClassInfoService.selectStuClassInfoByStudentId(studentId));
    }

    /**
     * 新增学生班级信息
     */
    @PreAuthorize("@ss.hasPermi('manage:classInfo:add')")
    @Log(title = "学生班级信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StuClassInfo stuClassInfo)
    {
        return toAjax(stuClassInfoService.insertStuClassInfo(stuClassInfo));
    }

    /**
     * 修改学生班级信息
     */
    @PreAuthorize("@ss.hasPermi('manage:classInfo:edit')")
    @Log(title = "学生班级信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StuClassInfo stuClassInfo)
    {
        return toAjax(stuClassInfoService.updateStuClassInfo(stuClassInfo));
    }

    /**
     * 删除学生班级信息
     */
    @PreAuthorize("@ss.hasPermi('manage:classInfo:remove')")
    @Log(title = "学生班级信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{studentIds}")
    public AjaxResult remove(@PathVariable String[] studentIds)
    {
        return toAjax(stuClassInfoService.deleteStuClassInfoByStudentIds(studentIds));
    }
}
